<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <form @submit.prevent="submit">
        <label>账号：</label>
        <input type="text" v-model="userFormData.username" /> <br />

        <label>密码：</label>
        <input type="password" v-model="userFormData.password" /> <br />

        <label>性别：</label>
        男
        <input type="radio" name="sex" :value="1" v-model="userFormData.sex" />
        女
        <input type="radio" name="sex" :value="0" v-model="userFormData.sex" />
        <br />

        <label>爱好：</label>
        抽烟
        <input type="checkbox" value="抽烟" v-model="userFormData.hobby" />
        喝酒
        <input type="checkbox" value="喝酒" v-model="userFormData.hobby" />
        烫头
        <input type="checkbox" value="烫头" v-model="userFormData.hobby" />
        <br />

        <label>所属校区：</label>
        <select v-model="userFormData.address">
          <option value="beijing">北京</option>
          <option value="shenzhen">深圳</option>
          <option value="shanghai">上海</option>
        </select>
        <br />

        <label>其他信息：</label>
        <textarea rows="5" v-model="userFormData.info"></textarea><br />
        <!-- <button type="submit" @click.prevent="submit">提交</button> -->
        <button type="submit">提交</button>
      </form>
    </div>
    <script src="./js/vue.js"></script>
    <script>
      const vm = new Vue({
        data: {
          userFormData: {
            username: "",
            password: "",
            sex: 1,
            hobby: [],
            address: "",
            info: "",
          },
        },
        methods: {
          submit() {
            console.log(this.userFormData);
          },
        },
      });
      vm.$mount("#app");
    </script>
  </body>
</html>
